Ext.BLANK_IMAGE_URL = 'resources/s.gif'; 
var Data;
//存储获取的数据
var DataStore;
//数据存储器
var Pager;
//分页器
var PerCount=10;
//每页的数据量
var Grid;
//GridPanel容器
var selectDataCompanyName;
var selectDataCompanyId;
var selectDataCompanyInfoId;
var selectDataCompanyInfoId;
var selectRowCompanyId;
var selectmemberId;
var t;
var temp=0;
var gridForm;
var taskIndex_Company=0;
var totalCount=1;
var pageCursor=0;

var ceshi;
function OnGetDataSuccess(jsonText,row)//数据获取成功
{
	try{
   		Data=Ext.util.JSON.decode(jsonText);
   		canclemsg();
	}catch(e){
		canclemsg();
//		alert(e.name+":"+e.message);
	}
	  totalCount=row;
  //将获取的Json数据格式化
   DataStore.loadData(GetPagerData(Data),false);
   DataStore.load();
  //这个很重要
   Pager.doLoad(0);
  //这个很重要
  
}

function GetPagerData(InData)//从静态数据中获取每页的数据
{
   var TempData=//为什么要用'd'作为json数据的根，因为从WebService获取Json数据经查看就是以'd'为根的
  {
    'd':[]
  };
  
   if(InData.d.length>PerCount)
  {
     for(var i=0;i<=PerCount-1;i++)
    {
       TempData.d.push(InData.d);
    }
  }
   else
  {
     for(var i=0;i<=InData.d.length-1;i++)
    {
       TempData.d.push(InData.d);
    }
  }
   return TempData;
}
function SerGrid()
{
	//获取数据之前的Loading数据
   Data=
  {
    'd':[
    {
      'id':'数据载入中',
      'companyId':'数据载入中',
      'companyName':'数据载入中',
      'memberId':'数据载入中',
      'loginId':'数据载入中',
      'memberType':'数据载入中',
      'contactName':'数据载入中',
      'contactSex':'数据载入中',
      'contactPosition':'数据载入中',
      'telNumber':'数据载入中',
      'mobileNumber':'数据载入中',
      'faxNumber':'数据载入中',
      'address':'数据载入中',
      'postCode':'数据载入中',
      'webSite1':'数据载入中',
      'webSite2':'数据载入中',
      'mainProduct':'数据载入中',
      'mainIndustry':'数据载入中',
      'businessMode':'数据载入中',
      'registeredCapital':'数据载入中',
      'establishedDate':'数据载入中',
      'establishedAddress':'数据载入中',
      'businessType':'数据载入中',
      'representative':'数据载入中',
      'employeesNum':'数据载入中',
      'annualTurnover':'数据载入中',
      'brandName':'数据载入中',
      'customerGroups':'数据载入中',
      'infoBody':'数据载入中',
      'lastUpdateTime':'数据载入中',
      'infoUrl':'数据载入中',
      'infoSource':'数据载入中',
      'status':'数据载入中',
      'customerType':'数据载入中',
      'isCollection':'数据载入中'
    }
    ]
  };
   DataStore=new Ext.data.Store(
  {
    //数据存储器
     proxy:new Ext.data.MemoryProxy(GetPagerData(Data)),
     reader:new Ext.data.JsonReader(
    {
       root:'d'
    },
    [
    {
       name:'id'
    },
    {
       name:'companyId'
    },
    {
       name:'companyName'
    },
    {
       name:'memberId'
    },
    {
       name:'loginId'
    },
    {
       name:'memberType'
    },
    {
       name:'contactName'
    },
    {
       name:'contactSex'
    },
    {
       name:'contactPosition'
    },
    {
       name:'telNumber'
    },
    {
       name:'mobileNumber'
    },
    {
       name:'faxNumber'
    },
    {
       name:'address'
    },
    {
       name:'postCode'
    },
    {
       name:'webSite1'
    },
    {
       name:'webSite2'
    },
    {
       name:'mainProduct'
    },
    {
       name:'mainIndustry'
    },
    {
       name:'businessMode'
    },
    {
       name:'registeredCapital'
    },
    {
       name:'establishedDate'
    },
    {
       name:'establishedAddress'
    },
    {
       name:'businessType'
    },
    {
       name:'representative'
    },
    {
       name:'employeesNum'
    },
    {
       name:'annualTurnover'
    },
    {
       name:'brandName'
    },
    {
       name:'customerGroups'
    },
    {
       name:'infoBody'
    },
    {
       name:'lastUpdateTime'
    },
    {
       name:'infoUrl'
    },
    {
       name:'infoSource'
    },
    {
       name:'status'
    },
    {
       name:'customerType'
    },
    {
    	name:'isCollection'
    }
    ])
  });
   var ColM=new Ext.grid.ColumnModel(//行定义器
  [
  {
     header:"联系状态",dataIndex:"status",sortable :false,editor: new Ext.form.ComboBox({  
                editable: true,  
                displayField: "status",  
                mode: "local",  
                store: new Ext.data.SimpleStore({  
                    fields: ["status"],  
                    data: [["未联系"],["已联系"],["无意向"],["有意向"],["需跟进"],["已签单"], ["已合作"]]  
                })  ,
               triggerAction: 'all',
               selectOnFocus:true,
                 listeners: {  //为Combo添加select事件   
        select: function(combo, record, index) {   // 该事件会返回选中的项对应在 store中的 record值. index参数是排列号.   
 	   	  		sendNSCommand('CHANGESTATUS'+";"+selectDataCompanyName+";"+record.data.status);
 	   	  		try{
					Data.d[Pager.cursor+selectRowCompanyId]['status']=record.data.status;
 	   	  		}catch(e){
// 	   	  			alert(e.message);
 	   	  		}
				
 	   	    }   
		        }  
            })
  },  {
   header:"客户类型",dataIndex:"customerType",sortable :false,editor: new Ext.form.ComboBox({  
                editable: true,  
                displayField: "customerType",  
                mode: "local",  
                store: new Ext.data.SimpleStore({  
                    fields: ["customerType"],  
                    data: [["普通客户"],["重要客户"]]  
                })  ,
               triggerAction: 'all',
               selectOnFocus:true,
                 listeners: {  //为Combo添加select事件   
        	select: function(combo, record, index) {   // 该事件会返回选中的项对应在 store中的 record值. index参数是排列号.   
 	   	  		sendNSCommand('CHANGECustomerType'+";"+selectDataCompanyName+";"+record.data.customerType);
				Data.d[Pager.cursor+selectRowCompanyId]['customerType']=record.data. customerType;
 	   	    }   
		        }  
            })
  },
  {
     header:"公司名称",dataIndex:"companyName",sortable :true,renderer: function(value){try{return "<a href='#'  style='color: black; text-decoration:none;'>"+value+"</a>";}catch(e){}}
  },
  {
     header:"会员类型",dataIndex:"memberType",hidden:true,sortable :true
  },
  {
     header:"联系人名称",dataIndex:"contactName",sortable :true
  },
  {
     header:"联系人性别",dataIndex:"contactSex",sortable :true,hidden:true
  },
  {
     header:"电话号码",dataIndex:"telNumber",sortable :true
  },
  {
     header:"手机号码",dataIndex:"mobileNumber",sortable :true
  },
  {
     header:"传真号码",dataIndex:"faxNumber",sortable :true
  },
  {
     header:"联系人职位",dataIndex:"contactPosition",sortable :true
  },
  {
     header:"地址",dataIndex:"address",sortable :true,hidden:true
  },
  {
     header:"邮编",dataIndex:"postCode",hidden:true,sortable :true
  },
  {
     header:"网站地址",dataIndex:"webSite1",hidden:true,sortable :true
  },
  {
     header:"主营产品",dataIndex:"mainProduct",sortable :true,hidden:true
  },
  {
     header:"主营行业",dataIndex:"mainIndustry",hidden:true,sortable :true
  },
  {
     header:"商业模式",dataIndex:"businessMode",hidden:true,sortable :true
  },
  {
     header:"注册资金",dataIndex:"registeredCapital",hidden:true,sortable :true
  },
  {
     header:"注册时间",dataIndex:"establishedDate",hidden:true,sortable :true
  },
  {
     header:"注册地址",dataIndex:"establishedAddress",hidden:true,sortable :true
  },
  {
     header:"商业模式",dataIndex:"businessType",hidden:true,sortable :true
  },
  {
     header:"法人代表",dataIndex:"representative",hidden:true,sortable :true
  },
  {
     header:"雇员人数",dataIndex:"employeesNum",hidden:true,sortable :true
  },
  {
     header:"年营业额",dataIndex:"annualTurnover",hidden:true,sortable :true
  },
  {
     header:"品牌名称",dataIndex:"brandName",hidden:true,sortable :true
  },
  {
     header:"用户群",dataIndex:"customerGroups",hidden:true,sortable :true
  },
  {
     header:"公司简介",dataIndex:"infoBody",hidden:true,sortable :true
  },
  {
     header:"收藏",dataIndex:"isCollection",hidden:true,sortable :true
  }
  ]);
   Pager=new Ext.PagingToolbar(
  {
     id:'Grid_Pager',
     pageSize:PerCount,
     store:DataStore,
     displayInfo:true,
     paramNames:
    {
       start:'start',limit:'limit',cid:'cid'
    },
     displayInfo:true,
     displayMsg:'显示第 {0} 条到 {1} 条记录，一共 {2} 条',
     emptyMsg:'没有数据',
     updateInfo:function ()//重写UpdateInfo
    {
       if(this.displayEl)
      {
         var count=this.store.getCount();
         var msg=count==0?this.emptyMsg:String.format(this.displayMsg,pageCursor+1,Math.min(pageCursor+this.pageSize-1,totalCount-1)+1,totalCount);
         this.displayEl.update(msg);
      }
    },
     onLoad:function (store,r,o)//重写OnLoad
    {
       if(!this.rendered)
      {
         this.dsLoaded=[store,r,o];
         return ;
      }
       var d=this.getPageData(),ap=d.activePage,ps=d.pages;
       this.afterTextEl.el.innerHTML=String.format(this.afterPageText,d.pages);
       this.field.dom.value=ap;
       this.first.setDisabled(ap==1);
       this.prev.setDisabled(ap==1);
       this.next.setDisabled(ap==ps);
       this.last.setDisabled(ap==ps);
       this.loading.enable();
       this.loading.setVisible(false);
       this.updateInfo();
    },
     doLoad:function (start)//重写doLoad
    {
    	if(start==0){
    		this.cursor=0;
    	}
       var TempData=
      {
        'd':[]
      };
       var i=0;
       var len=this.pageSize;
       for(i=0;i<len;i++)
      {
         if(Data.d[start+i]!=null)
        {
           TempData.d.push(Data.d[start+i]);
        }
      }
       this.store.loadData(TempData,false);
    },
     readPage : function(d){
     	this.cursor=this.pageSize*(this.field.dom.value-1);
     	 t=this.cursor;
       	this.doLoad(t);
       	pageCursor=t;
       	sendNSCommand('CRMTURNPAGE;'+t+";"+(t+this.pageSize));
    },
     getPageData:function ()//重写getPageData
    {
       var A=totalCount;
       return{
			total:A,
			activePage:Math.ceil((pageCursor+this.pageSize)/this.pageSize),
			pages:A<this.pageSize?1:Math.ceil(A/this.pageSize)}},
     onClick:function (which)//重写onClick
    {
       switch(which)
      {
      	
         case "first":
         t=0;
         this.cursor=Math.max(0,t-this.pageSize);
         this.doLoad(0);
         pageCursor=0;
         sendNSCommand('CRMTURNPAGE;'+t+";"+(t+this.pageSize));
         break;
         case "prev":
         t=pageCursor;
         this.cursor=Math.max(0,t-this.pageSize);
         this.doLoad(Math.max(0,t-this.pageSize));
         pageCursor=pageCursor-10;
         sendNSCommand('CRMTURNPAGE;'+(pageCursor)+";"+(pageCursor+this.pageSize));
         break;
         case "next":
         t=this.cursor;
         this.cursor=t+this.pageSize;
         this.doLoad(t+this.pageSize);
         pageCursor+=t+this.pageSize;   
         sendNSCommand('CRMTURNPAGE;'+(pageCursor)+";"+(pageCursor+this.pageSize));
         break;
         case "last":
         var total=totalCount;
         var extra=total%this.pageSize;
         var lastStart=extra?(total-extra):total-this.pageSize;
         this.cursor=extra?(total-extra):total-this.pageSize;
         this.doLoad(lastStart);
         pageCursor=lastStart; 
         sendNSCommand('CRMTURNPAGE;'+(lastStart)+";"+(lastStart+this.pageSize));
         break;
         case "refresh":
         t=this.cursor;
         this.cursor=t;
         this.doLoad(t);
         break;
      }
    }
  });
  
  
  
    gridForm = new Ext.FormPanel({
        id: 'company-crm-form',
        frame: true,
        labelAlign: 'left',
        title: '名录列表',
        bodyStyle:'padding:5px',
        width: 800,
        layout: 'column',
        enableKeyEvents : true, 
	
        items: [{
            columnWidth: 1,
            layout: 'fit',
            id:'item1',
            items: {
           		id:'panelGrid',
	            xtype: 'editorgrid',
	            store:DataStore,
	            cm:ColM,
	            sm: new Ext.grid.RowSelectionModel({
	                singleSelect: true,
	                listeners: {
	                    rowselect: function(sm, row, rec) {
	                    	selectDataCompanyName = rec.data.companyName;
	                    	selectDataCompanyId=rec.data.id;
	                    	selectDataCompanyInfoId=rec.data.companyId
	                    	selectRowCompanyId=row;
	                    	selectmemberId=rec.data.memberId;
	                        Ext.getCmp("company-crm-form").getForm().loadRecord(rec);
	                        Ext.getCmp("memorandum_Value").setValue("");
	                        Ext.getCmp("submitCon").setVisible(false); 
	                        addStatue=0;
	                        if(Ext.getCmp("memorandum_Value").getValue()!=""){
	                        	Ext.getCmp("memorandum_Value").getEl().dom.readOnly=false;
	                        }else{
	                        	Ext.getCmp("memorandum_Value").getEl().dom.readOnly=true;
	                        	Ext.getCmp("submitCon").setVisible(false);
	                        }
	                        if(selectDataCompanyId!=""){
	                        	sendNSCommand('GETMemorandum'+";"+selectDataCompanyId+";"+selectDataCompanyName);
	                        }
	                    }
	                }
	            }),
	            tbar:[{
	            		xtype : 'splitbutton',
			            text:'联系状态',
			            tooltip:'联系状态',
			            id:'selectStatu',
			            menu: new Ext.menu.Menu({
	                    items: [{
	                        	text: '全部',handler:selectStatus
		                    },{
	                        	text: '未联系',handler:selectStatus
		                    },{
		                        text: '已联系',handler:selectStatus
		                    },{
		                        text: '无意向',handler:selectStatus
		                    },{
		                        text: '有意向',handler:selectStatus
		                    },{
		                        text: '需跟进',handler:selectStatus
		                    },{
		                        text: '已签单',handler:selectStatus
		                    },{
		                        text: '已合作',handler:selectStatus
		                    }]
	                   }),
	                   iconCls:'dataFinishing'
	                   
				        },'-',{
	            		xtype : 'splitbutton',
			            text:'客户类型',
			            tooltip:'客户类型',
			            id:'selectCustomer',
			            menu: new Ext.menu.Menu({
	                    items: [{
	                        	text: '全部',handler:selectCustomer
		                    },{
	                        	text: '普通客户',handler:selectCustomer
		                    },{
		                        text: '重要客户',handler:selectCustomer
		                    },{
		                        text: '自定义客户',handler:selectCustomer
		                    }]
	                   }),
	                   iconCls:'dataFinishing'
				        },'-',{
			            text:'删除收藏',
			            tooltip:'删除收藏',
			            handler:function (){
			            		if(selectDataCompanyId==""){
			            			alert("请选择需要删除的数据");
		            				return;
			            		}
			            		DataStore.remove(DataStore.getAt(selectRowCompanyId));
			            		Data.d.splice(Pager.cursor+selectRowCompanyId,1);		            		
			            		sendNSCommand('deleteCompanyCrmData'+";"+selectDataCompanyId+";"+selectDataCompanyInfoId);
			            		selectDataCompanyId="";
			            	} ,
			            buttonAlign:'center',
			            iconCls:'delete'
				        }
			        /*--,'-', {
			            text:'重要客户',
			            tooltip:'重要客户',
			            handler:function (){sendNSCommand('getCompanyByCustomerType'+"重要客户");} ,
			            buttonAlign:'center',
			            iconCls:'start'
				     }*/
			        ,'-', {
			            text:'导出数据',
			            tooltip:'导出数据',
			            
			            handler:function (){
			            		msg();
			            		sendNSCommand('derivedCrmExcel');
			            } ,
			            buttonAlign:'center',
			            iconCls:'download'
				        },'-', {
			            text:'添加新公司资料',
			            tooltip:'添加新公司资料',
			            
			            handler:function (){
			            	try{
			            	Ext.getCmp("company-crm-form").getForm().reset();
			            	selectDataCompanyId="";
			            	}catch(e){
			            		alert(e.message);
			            	}
			            } ,
			            buttonAlign:'center',
			            iconCls:'addData'
				        },'-',new Ext.form.TextField({
				        	id:'searchText', 
							name: 'searchText',
							emptyText : '请输入公司名称',
							style:'background-image:url("image/search.gif");background-repeat:no-repeat;padding-left:20px;',
    						listeners: {
    							'specialkey':function(field, e){
    								if (e.getKey() == Ext.EventObject.ENTER) {
    									sendNSCommand("searchCompanyName;"+Ext.getCmp("searchText").getValue());
    									
    								}
    							}
                       		} 

      					})

			        ],
	            height: 310,
	            border: true,
		        listeners: {
		        	render: function(g) {
		        		g.getSelectionModel().selectRow(0);
		        	},
		        	delay: 10 // Allow rows to be rendered.
		        },
		        bbar:Pager
        	}
        },{
        	columnWidth: 1,
            xtype: 'panel',
            autoHeight: true,
            items: [
                        
           {   layout : 'table',
               layoutConfig : {
                 columns : 5 //设置表格布局默认列数为4列
               },
               
           
 	items:[
	{
     title:'',
     height:2,
     colspan : 5  //设置跨列
    },	
    {
     title:'',
     colspan : 1 ,  //设置跨列
	 defaultType: 'textfield', layout : 'form',
	 items: [{fieldLabel: '公司名称',id: 'companyName',name: 'companyName'
            },{  fieldLabel: '注册时间',id: 'establishedDate',name: 'establishedDate'
            },{fieldLabel: '会员类型',id: 'memberType',name: 'memberType'
            },{fieldLabel: '联系人名称',id: 'contactName',name: 'contactName'
            },{fieldLabel: '联系人性别',id: 'contactSex',name: 'contactSex'
            },{fieldLabel: '联系人职位',id: 'contactPosition',name: 'contactPosition'
            },{fieldLabel: '电话号码',id: 'telNumber',name: 'telNumber'
            },{fieldLabel: '手机号码',id: 'mobileNumber',name: 'mobileNumber'
            } ]
    },	
	
	{
     title:'',
     colspan : 1 ,  //设置跨列
	 width:15
    },	
    {
     title:'',
     colspan : 1 ,  //设置跨列
	 defaultType: 'textfield', layout : 'form',
	  items: [{fieldLabel: '传真号码',id: 'faxNumber',name: 'faxNumber'
            },{fieldLabel: '商业类型',id: 'businessType',name: 'businessType'
            },{fieldLabel: '商业模式',id: 'businessMode',name: 'businessMode'
            },{fieldLabel: '地址',id: 'address',name: 'address'
            },{fieldLabel: '邮编',id: 'postCode',name: 'postCode'
            },{fieldLabel: '网站地址1',id: 'webSite1',name: 'webSite1'
            },{fieldLabel: '主营产品',id: 'mainProduct',name: 'mainProduct'
            },{fieldLabel: '主营行业',id: 'mainIndustry',name: 'mainIndustry'
            }]
    },	
    	{
     title:'',
     colspan : 1 ,  //设置跨列
	 width:15
    },	
    
        {
     title:'',
     colspan : 1 ,  //设置跨列
	 defaultType: 'textfield', layout : 'form',
	  items: [{fieldLabel: '注册资金',id: 'registeredCapital',name: 'registeredCapital'
            },{fieldLabel: '注册地址',id: 'establishedAddress',name: 'establishedAddress'
            },{fieldLabel: '法人代表',id: 'representative',name: 'representative'
            },{fieldLabel: '雇员人数',id: 'employeesNum',name: 'employeesNum'
            },{fieldLabel: '年营业额',id: 'annualTurnover',name: 'annualTurnover'
            },{fieldLabel: '品牌名称',id: 'brandName',name: 'brandName'
            },{fieldLabel: '用户群',id: 'customerGroups',name: 'customerGroups'
            },{fieldLabel: '其他'}]
    },
    {
     title:'',
     colspan : 5   //设置跨列
	 , 
	 defaultType: 'textfield', layout : 'form',
	  items: [
			 {fieldLabel: '公司简介',xtype: 'textarea',id: 'infoBody',name: 'infoBody',anchor: '100% -53',height:'200'
            } ]
    },{
     title:'',
     colspan : 5 ,  //设置跨列
     defaultType: 'textfield',
	  items: [{id: 'status',name: 'status',hidden:true
            },{id: 'customerType',name: 'customerType',hidden:true
            }]
    }	
    
    
    ]

					}
				]
        }],
        			     buttons:[      
                             {
                             id:"saveCon",
                             text:"保存",   
                              buttonAlign:'center', 
                              width:'150',
                              visible:false,                           
                              handler:function(){
                              	try{
                              		if(Ext.getCmp('companyName').getValue()==""){
                              			alert("请填写资料");
                              			return;
                              		}
                              	var saveData="{\"id\":\""+selectDataCompanyId+"\",\"companyName\":\""+Ext.getCmp('companyName').getValue()+"\",\"establishedDate\":\""+Ext.getCmp('establishedDate').getValue()+"\",\"memberType\":\""+Ext.getCmp('memberType').getValue()+"\",\"contactName\":\""+Ext.getCmp('contactName').getValue()+"\",\"contactSex\":\""+Ext.getCmp('contactSex').getValue()+"\",\"contactPosition\":\""+Ext.getCmp('contactPosition').getValue()+"\",\"telNumber\":\""+Ext.getCmp('telNumber').getValue()+"\",\"mobileNumber\":\""+Ext.getCmp('mobileNumber').getValue()+"\",\"faxNumber\":\""+Ext.getCmp('faxNumber').getValue()+"\",\"businessType\":\""+Ext.getCmp('businessType').getValue()+"\",\"businessMode\":\""+Ext.getCmp('businessMode').getValue()+"\",\"address\":\""+Ext.getCmp('address').getValue()+"\",\"postCode\":\""+Ext.getCmp('postCode').getValue()+"\",\"webSite1\":\""+Ext.getCmp('webSite1').getValue()+"\",\"mainProduct\":\""+Ext.getCmp('mainProduct').getValue()+"\",\"mainIndustry\":\""+Ext.getCmp('mainIndustry').getValue()+"\",\"registeredCapital\":\""+Ext.getCmp('registeredCapital').getValue()+"\",\"establishedAddress\":\""+Ext.getCmp('establishedAddress').getValue()+"\",\"representative\":\""+Ext.getCmp('representative').getValue()+"\",\"employeesNum\":\""+Ext.getCmp('employeesNum').getValue()+"\",\"annualTurnover\":\""+Ext.getCmp('annualTurnover').getValue()+"\",\"brandName\":\""+Ext.getCmp('brandName').getValue()+"\",\"customerGroups\":\""+Ext.getCmp('customerGroups').getValue()+"\",\"infoBody\":\""+Ext.getCmp('infoBody').getValue()+"\",\"status\":\""+Ext.getCmp('status').getValue()+"\",\"customerType\":\""+Ext.getCmp('customerType').getValue()+"\"}";
                              	sendNSCommand("saveorupdateCrm@"+saveData);
                              	}catch(e){
                              		alert(e.message);
                              	}
                              }}      
                         ] 
    });



//   DataStore.loadData(GetPagerData(Data),false);
   DataStore.load();
//   Pager.doLoad(0);
  //这个很重要，用来显示Loading数据
}

var setSta="全部";
var setCus="全部";
function selectStatus(statu){
	setSta=statu.text;
	Ext.getCmp("selectStatu").setText(statu.text);
	sendNSCommand('selectConditions;'+setCus+";"+setSta);
}

function selectCustomer(statu){
	setCus=statu.text;
	Ext.getCmp("selectCustomer").setText(statu.text);
	sendNSCommand('selectConditions;'+setCus+";"+setSta);
}

function Main()
{
	SerGrid();
   gridForm.render(document.getElementById("right"));
 //   GetDataFromWebService();
 
}

Ext.onReady(function(){
	Main();
	msg('正在加载搜索数据，请稍后。。。');
//	var Request = new Object();
//	Request = GetRequest();
	sendNSCommand('GETCustomer');
	
});

function openCompanyUrl(){
	if(selectmemberId!=null && selectmemberId!=""){
		var url="http://www.diyiminglu.com/company_Ali/"+selectmemberId.substring(0,1)+"/"+selectmemberId.substring(1,2)+"/"+selectmemberId+".htm";
		window.open(url);
	}
}



function GetRequest() {

   var url = location.search; //获取url中"?"符后的字串

   var theRequest = new Object();

   if (url.indexOf("?") != -1) {

      var str = url.substr(1);

      strs = str.split("&");

      for(var i = 0; i < strs.length; i ++) {

         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);

      }

   }

   return theRequest;

}

